//
//  CXTabBarConfig.m
//  喜马拉雅FM
//
//  Created by hcios on 2017/8/26.
//  Copyright © 2017年 hcios. All rights reserved.
//

#import "CXTabBarConfig.h"
#import <UIKit/UIKit.h>

#import "CXHomeViewController.h"
#import "ZxFMMyLisitenViewController.h"
#import "CXCenterViewController.h"
#import "CXDiscoverViewController.h"
#import "ZxFMLoginTableViewController.h"

#import "CXTabBarViewController.h"
#import "CXNavigationViewController.h"
#import "CXTabBarItem.h"

@implementation CXTabBarConfig

+(CXTabBarViewController *)cx_configTabBarController{

    CXTabBarViewController *tabBarVC = [CXTabBarViewController tabBarVCWithSubControllwes:[self getTabBarSubControllers] tabBarItems:[self setupAttributes]];
    return tabBarVC;
}


+(NSArray<UIViewController *> *)getTabBarSubControllers {
    
    //首页
    CXHomeViewController *homeVC = [[CXHomeViewController alloc] init];
//    homeVC.view.backgroundColor = [UIColor redColor];
    CXNavigationViewController *navHomeVC = [self cx_addNavigationBarForViewController:homeVC];
    
    //我听
    ZxFMMyLisitenViewController *listenVC = [[ZxFMMyLisitenViewController alloc] init];
    listenVC.view.backgroundColor = [UIColor whiteColor];
    CXNavigationViewController *navListenVC = [self cx_addNavigationBarForViewController:listenVC];
    
    //发现
    CXDiscoverViewController *discoverVC = [[CXDiscoverViewController alloc] init];
    discoverVC.view.backgroundColor = [UIColor whiteColor];
    CXNavigationViewController *navDiscoverVC = [self cx_addNavigationBarForViewController:discoverVC];
    
    //登录
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"ZxFMLoginTableViewController" bundle:nil];
    CXNavigationViewController *navLoginVC = [self cx_addNavigationBarForViewController:[storyBoard instantiateInitialViewController]];
    
    
    NSArray *subControllers = @[navHomeVC, navListenVC, navDiscoverVC, navLoginVC];
    return subControllers;
}


+(CXNavigationViewController *)cx_addNavigationBarForViewController:(UIViewController *)vc{
    CXNavigationViewController *navVC = [[CXNavigationViewController alloc] initWithRootViewController:vc];
    
    return navVC;
}


+(NSArray<CXTabBarItem *> *)setupAttributes{
    CXTabBarItem *attribute1 = [[CXTabBarItem alloc] init];
    attribute1.selectedImage = [UIImage imageNamed:@"tabbar_icon_homepage_pressed"];
    attribute1.normalImage = [UIImage imageNamed:@"tabbar_icon_homepage_normal"];
    attribute1.normalTitleFont = [UIFont systemFontOfSize:10];
    attribute1.selectedTitleFont = [UIFont systemFontOfSize:10];
    attribute1.selectedTitleColor = [UIColor colorWithRed:82/255.0 green:177/255.0 blue:51/255.0 alpha:1];
    
    CXTabBarItem *attribute2 = [[CXTabBarItem alloc] init];
    attribute2.selectedImage = [UIImage imageNamed:@"tabbar_icon_hear_pressed"];
    attribute2.normalImage = [UIImage imageNamed:@"tabbar_icon_hear_normal"];
    attribute2.normalTitleFont = [UIFont systemFontOfSize:10];
    attribute2.selectedTitleFont = [UIFont systemFontOfSize:10];
    attribute2.selectedTitleColor = [UIColor colorWithRed:82/255.0 green:177/255.0 blue:51/255.0 alpha:1];
    
    CXTabBarItem *attribute3 = [[CXTabBarItem alloc] init];
    attribute3.selectedImage = [UIImage imageNamed:@"tabbar_icon_find_pressed"];
    attribute3.normalImage = [UIImage imageNamed:@"tabbar_icon_find_normal"];
    attribute3.normalTitleFont = [UIFont systemFontOfSize:10];
    attribute3.selectedTitleFont = [UIFont systemFontOfSize:10];
    attribute3.selectedTitleColor = [UIColor colorWithRed:82/255.0 green:177/255.0 blue:51/255.0 alpha:1];
    
    CXTabBarItem *attribute4 = [[CXTabBarItem alloc] init];
    attribute4.selectedImage = [UIImage imageNamed:@"tabbar_icon_my_pressed2"];
    attribute4.normalImage = [UIImage imageNamed:@"tabbar_icon_my_normal2"];
    attribute4.normalTitleFont = [UIFont systemFontOfSize:10];
    attribute4.selectedTitleFont = [UIFont systemFontOfSize:10];
    attribute4.selectedTitleColor = [UIColor colorWithRed:82/255.0 green:177/255.0 blue:51/255.0 alpha:1];
    
    return @[attribute1, attribute2, attribute3, attribute4];
}
@end
